﻿<Window x:Class="AppDesigner.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Shared="clr-namespace:AppDesigner.Shared"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:dd="clr-namespace:AppDesigner.DragDropEx"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="APPDesigner"
        Background="{DynamicResource CommonBackBrush}"
        DataContext="{Binding MainVm,
                              Source={StaticResource Locator}}"
        ResizeMode="NoResize"
        WindowStartupLocation="CenterScreen"
        WindowState="Maximized"
        d:DesignHeight="768"
        d:DesignWidth="1366"
        mc:Ignorable="d">
    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="DesignState">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1">
                        <VisualTransition.GeneratedEasingFunction>
                            <QuarticEase EasingMode="EaseInOut" />
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="SinglePage">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SingleGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <EasingDoubleKeyFrame KeyTime="0" Value="-768" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PagesGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-768" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="ManyPages">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SingleGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-768" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PagesGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <EasingDoubleKeyFrame KeyTime="0" Value="-768" />
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <Button Margin="0,0,20,0" Content="New Page" />
            <Button Margin="0,0,20,0" Content="Convert" />
            <Button Margin="0,0,20,0"
                    Click="SeePages"
                    Content="See Pages" />
            <Button Margin="0,0,20,0"
                    Click="ContinueDesign"
                    Content="Continue" />

        </StackPanel>
        <Grid x:Name="SingleGrid"
              Grid.Row="1"
              RenderTransformOrigin="0.5,0.5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Grid.RenderTransform>
                <TransformGroup>
                    <ScaleTransform />
                    <SkewTransform />
                    <RotateTransform />
                    <TranslateTransform />
                </TransformGroup>
            </Grid.RenderTransform>

            <Grid Grid.RowSpan="2" Grid.Column="0">
                <Grid Width="250" Background="White">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel>
                        <TextBlock HorizontalAlignment="Center" Text="FileExplorer" />
                    </StackPanel>
                    <StackPanel Grid.Row="1">
                        <TextBlock HorizontalAlignment="Center" Text="PropertyEditor" />
                    </StackPanel>
                </Grid>
            </Grid>
            <Border Grid.RowSpan="2"
                    Grid.Column="1"
                    BorderBrush="{DynamicResource CommonForeBrush}"
                    BorderThickness="1"
                    DataContext="{Binding DrawViewModel}">

                <Grid x:Name="DesignPanel">
                    <Grid.Background>
                        <ImageBrush ImageSource="/Images/builder_bg_texture_tile.png"
                                    TileMode="Tile"
                                    Viewport="0,0,4,4"
                                    ViewportUnits="Absolute" />
                    </Grid.Background>
                    <Canvas Width="384"
                            Height="640"
                            Background="{DynamicResource CommonBackBrush}"
                            dd:BindableDrapDrop.DropHandler="{Binding}"
                            dd:BindableDrapDrop.IsDropTarget="True" />
                </Grid>

            </Border>

            <Grid Grid.RowSpan="2"
                  Grid.Column="2"
                  DataContext="{Binding ToolBoxViewModel}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Border Background="{StaticResource CommonForeBrush}"
                        BorderBrush="{DynamicResource LightDarkBrush}"
                        BorderThickness="0,0,0,2">
                    <TextBlock Margin="65.061,0"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Top"
                               Background="{DynamicResource CommonForeBrush}"
                               FontSize="18.667"
                               FontWeight="Bold"
                               Foreground="{DynamicResource CommonBackBrush}"
                               Text="控件集合" />
                </Border>
                <ListBox x:Name="ControlList"
                         Grid.Row="1"
                         Width="250"
                         Background="{DynamicResource CommonForeBrush}"
                         BorderThickness="0"
                         Foreground="{DynamicResource CommonForeBrush}"
                         ItemsSource="{Binding Controls}"
                         SelectedItem="{Binding SelectedControl,
                                                Mode=TwoWay}"
                         dd:BindableDrapDrop.DragHandler="{Binding}"
                         dd:BindableDrapDrop.IsDragSource="True">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Width="240" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Width="60"
                                        Height="70"
                                        Margin="5">
                                <Image HorizontalAlignment="Center"
                                       Source="{Binding ImageUrl}"
                                       Stretch="None" />
                                <TextBlock HorizontalAlignment="Center"
                                           VerticalAlignment="Stretch"
                                           Foreground="{StaticResource CommonBackBrush}"
                                           Text="{Binding DisplayName}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Grid>
        <Grid x:Name="PagesGrid"
              Grid.Row="1"
              DataContext="{Binding PagesViewModel}"
              RenderTransformOrigin="0.5,0.5">
            <Grid.RenderTransform>
                <TransformGroup>
                    <ScaleTransform />
                    <SkewTransform />
                    <RotateTransform />
                    <TranslateTransform Y="-768" />
                </TransformGroup>
            </Grid.RenderTransform>
            <Grid.Background>
                <ImageBrush ImageSource="/Images/builder_bg_texture_tile.png"
                            TileMode="Tile"
                            Viewport="0,0,4,4"
                            ViewportUnits="Absolute" />
            </Grid.Background>
            <ListBox x:Name="PagesItems" ItemsSource="{Binding Pages}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border Width="170"
                                Height="284"
                                Margin="5"
                                Background="DarkGray">
                            <TextBlock Margin="5,5,0,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       FontSize="21.333"
                                       Foreground="White"
                                       Text="{Binding}" />
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Width="1330" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </Grid>
    </Grid>
</Window>
